var App = require('app');

App.FormRoute = Ember.Route.extend({
	model: function(params) {
		var uri = this.router.location.location.hash;
		if (uri.indexOf("data") > -1 || uri.indexOf("report") > -1) {
			if (Util.isNotEmpty(params.form_id)) {
				Vari.CurrFormId = params.form_id;
			} 
			return;
		}
		if (Util.isNotEmpty(params.form_id)) {
			Vari.CurrFormId = params.form_id;
			Vari.frm = FormUtil.retriveInfo(Vari.CurrFormId);
			return Vari.frm;
		} else {
			var form = FormUtil.newForm();
			Vari.CurrFormId = form.get("id");
			Vari.frm = form;
			return Vari.frm; 
		}		
	},
	setupController : function(controller, model) {
		
	},	
});

App.FormDisplayRoute = Ember.Route.extend({
	model: function(params) {
		
	},
	setupController : function(controller, model) {				
		Vari.frm = FormUtil.retriveInfo(Vari.CurrFormId);
		controller.set('content', Vari.frm);
	},
});

App.FormViewRoute = Ember.Route.extend({
	model: function(params) {
		
	},
	setupController : function(controller, model) {
		Vari.frm = FormUtil.retriveInfo(Vari.CurrFormId);
		controller.set('content', Vari.frm);
	},
});

App.FormEditRoute = Ember.Route.extend({
	model: function(params) {
		
	},
	setupController : function(controller, model) {
		Vari.tpl = FormUtil.retriveTpl(); // for new fields
		Vari.frm = FormUtil.retriveInfo(Vari.CurrFormId);
		controller.set('content', Vari.frm);
	},
});

App.FormDataRoute = Ember.Route.extend({
	model: function(params) {
		
	},
	setupController : function(controller, model) {
		Vari.dat = FormUtil.retriveData(Vari.CurrFormId);
		controller.set('content', Vari.dat);
	},
	
});

App.FormReportRoute = Ember.Route.extend({
	model: function(params) {
		
	},
	setupController : function(controller, model) {
		Vari.rpt = FormUtil.retriveReport(Vari.CurrFormId);
		
		controller.set('content', Vari.rpt);
	}
	
});
